package algo_lignes_sites.ihm.couche;

import algo_lignes_sites.data.Data_ls;
import algo_lignes_sites.data.junction.A_Junction;
import algo_lignes_sites.data.junction.JunctionDER;
import algo_lignes_sites.data.junction.JunctionREF;
import com.sun.nio.zipfs.ZipDirectoryStream;
import commons.data.I_Data;
import commons.drawing.CircleDrawable;
import commons.drawing.I_Drawable;
import commons.drawing.couche.CoucheBasic;
import commons.drawing.UtilsDrawing;
import commons.utils.primitive_geom.Rect_d;
import java.awt.Color;
import java.util.ArrayList;


public class CoucheContrainteGeomNode extends CoucheBasic {

	public static enum TypeContraineGeom {RAYON, ESPACE_AUTOUR, ZS, ZC, ZIT, ZIN,
											ALL/* toutes les infos précédentes */,
											DIMENSION /* RAYON + ESPACE_AUTOUR */,
											PARAM_TOPO /* ZS + ZC */,
											ZONE_INFLUENCE /* ZIT + ZIN */}
	
	private TypeContraineGeom tcg;
	private boolean bREF;
	
	public CoucheContrainteGeomNode (Data_ls data, TypeContraineGeom tcg, boolean bREF) {
		super("RayonSimplifNode", null, data);
		this.tcg = tcg;
		this.bREF = bREF;
	}

	@Override
	protected ArrayList<I_Drawable> getDrawables(Rect_d rectVisu) {

		// recup des nodes
		ArrayList<A_Junction> vToDraw = bREF ?	data.getData(I_Data.DataType.NODE_REF_LS, rectVisu) : data.getData(I_Data.DataType.NODE_DER_LS, rectVisu);

		ArrayList<I_Drawable> vRes = new ArrayList<I_Drawable>(vToDraw.size());

		for (A_Junction j : vToDraw) {
			addDrawables(j, tcg, vRes);
		}

		return vRes;
	}
	
	static public void addDrawables(A_Junction node, TypeContraineGeom tcg, ArrayList<I_Drawable> vDrawable) {
		assert(node.isNode());
		double rayon_node = node.getRayonNodeFinal();
		

		if (tcg==TypeContraineGeom.ALL || tcg==TypeContraineGeom.ZONE_INFLUENCE || tcg==TypeContraineGeom.ZIT)
			// disque gris
			vDrawable.add(new CircleDrawable(node, rayon_node * node.nodeData.contrainteGeom.zit, 1,  null, Color.GRAY, true));

		if (tcg==TypeContraineGeom.ALL || tcg==TypeContraineGeom.ZONE_INFLUENCE || tcg==TypeContraineGeom.ZIN)
			// disque gris clair
			vDrawable.add(new CircleDrawable(node, rayon_node * node.nodeData.contrainteGeom.zit * node.nodeData.contrainteGeom.zin, 1,  null, Color.LIGHT_GRAY, true));

		
		
		if (tcg==TypeContraineGeom.ALL || tcg==TypeContraineGeom.DIMENSION || tcg==TypeContraineGeom.RAYON)
			// cercle trait plein de la couleur naturelle du node, epaisseur 2
			vDrawable.add(new CircleDrawable(node, rayon_node, 2,  node.nodeData.color, null, false));
		
		if (tcg==TypeContraineGeom.ALL || tcg==TypeContraineGeom.DIMENSION || tcg==TypeContraineGeom.ESPACE_AUTOUR)
			// cercle trait plein de la couleur naturelle du node, epaisseur 1
			vDrawable.add(new CircleDrawable(node, node.getRayonNodeFinal_avecEspaceAutour(), 1,  node.nodeData.color, null, false));
		
		
		
		if (tcg==TypeContraineGeom.ALL || tcg==TypeContraineGeom.PARAM_TOPO || tcg==TypeContraineGeom.ZS) {
			// cercle trait pointillé gris foncé, epaisseur 2
			vDrawable.add(new CircleDrawable(node, rayon_node * node.nodeData.contrainteGeom.zs, 2,  Color.LIGHT_GRAY, null, true)); // rayon souhaité de simplification
			vDrawable.add(new CircleDrawable(node, node.nodeData.rayon_Simplification_m, 2,  Color.DARK_GRAY, null, true)); // rayon reel de simplification
		}
		
		if (tcg==TypeContraineGeom.ALL || tcg==TypeContraineGeom.PARAM_TOPO || tcg==TypeContraineGeom.ZC)
			// cercle trait pointillé gris foncé, epaisseur 1
			vDrawable.add(new CircleDrawable(node, rayon_node * node.nodeData.contrainteGeom.zc, 1,  Color.DARK_GRAY, null, true));
		
		
	}



}
